//
//  DepartmentTableViewController.m
//  AddressBook
//
//  Created by mac on 2017/8/29.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "DepartmentTableViewController.h"
#import "DepartmentAddressTableViewController.h"

@interface DepartmentTableViewController ()

@end

@implementation DepartmentTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    if (self.modelArr.count != 0) {
        // 先取出每一个部门mdoel
        for (DepartmentModel *model in self.modelArr) {
            // 从每一个部门model取出联系人mdoel
            for (PeopleModel *pModel in model.info) {
                // 联系人model有三个属性
                NSLog(@"部门 = %@, name = %@, people = %@", pModel.section_name, pModel.user_name, pModel.user_phone);
            }
        }
    }
}


#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.modelArr.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *depar = @"deparCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:depar];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:depar];
    }
    
    // 赋值部门名字
    cell.textLabel.text = self.modelArr[indexPath.row].section_name;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    
}





@end
